package com.sky.mapper;

import com.sky.dto.EmployeeDTO;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.dto.PasswordEditDTO;
import com.sky.entity.Employee;
import com.sky.pojo.StatusUpdate;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    @Select("select * from employee where username = #{username}")
    public Employee selectEmployeeByName(String username);


    @Insert("insert into employee (id, name, username, password, phone, sex, id_number, status) value\n" +
            "(#{id}, #{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber}, #{status})")
    void addEmployee(Employee employee);

    @Select("select id, name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user from employee where id = #{id}")
    Employee selectEmployeeById(Long id);

    @Update("update employee set id_number = #{idNumber}, name = #{name}, phone = #{phone}, sex= #{sex}, username= #{username} where id =#{id}")
    void updateEmployeeById(EmployeeDTO employeeDTO);


    // @Select("select id, name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user from employee")
    List<Employee> selectEmployeePage(EmployeePageQueryDTO employeePageQueryDTO);

    @Select("select count(*) from employee")
    Integer count();

    @Update("update employee set status=#{status} where id =#{id}")
    void status(StatusUpdate statusUpdate);

    @Update("update employee set password = #{newPassword} where id =#{empId}")
    void editPassword(PasswordEditDTO passwordEditDTO);
}
